DIY Exercise 6-1: Troubleshoot and refactor a Mule application

Time estimate: 2 hours

Objectives

In this exercise, you troubleshoot and refactor a Mule application. You will:

·       Diagnose and repair common Mule event-related, RAML-related, and connector-related issues.

·       Organize and refactor Mule flows.

Scenario

Your colleagues need assistance; they have modified the Accounts API specification to include a new salesID field and broken the Accounts API implementation when trying to update it. Review their changes and then troubleshoot and fix the API implementation. 

Import the starting project

Import /files/module06/accounts-mod06-debugging-starter.jar (in the MUFundamentals4.x DIY Files zip that you can download from the Course Resources) into Anypoint Studio.

Note: This Mule project file has errors specifically designed to help you learn to diagnose common errors. Do not use your previous solution.

Review the modified API in the starter project

Review the updated files in the api folder located in the accounts-mod06-debugging-starter project. Look for any issues with the updated RAML API. Compare the RAML data type files with the examples and identify any differences that might be causing errors.

Review the existing (broken) implementation

Review implementation.xml in the accounts-mod06-debugging-starter project. Try to identify any issues before you debug the Mule application.

Troubleshoot and fix the Mule application

Debug the Mule application and fix all the errors that prevent it from starting up.

Hint: The project references a flow that is in another Mule application called templates. You will need to import the template application as a dependency into your local m2 repository. For help, follow the step-by-step Install a Mule application as a dependency walkthrough.

Troubleshoot and fix database connectivity errors

Verify the database driver and connection information is correct. If you get database connectivity errors, you can use the following MySQL database credentials:

·       Host: mudb.learn.mulesoft.com

·       Port: 3306

·       User: mule

·       Password: mule

·       Database: training

·       Table: flights_customers

Here is the expected output from the Mule application where salesId is a concatenation of id, first name, last name, postal, and creationDate:

[

  {

    "salesId": "100Alice Green941082018-10-01T23:57:59Z+0:00"

    "id": "100"

    "firstName": "Alice",

    "lastName": "Green",

    "address": "77 Geary St., San Francisco"

    "postal": "94108"

    "country": "USA",

    "creationDate": "2018-10-01T23:57:59Z+0:00",

    "accountType": "business",

    "miles": 1000

  }

]

Refactor the Mule application to use parameterized queries

Refactor the Mule application so that the SQL statements refer to parameterized queries instead of directly inserting query parameters in the database components.

Test the APIkit Console and make sure it works

Make sure the APIkit Console’s view is able to load without any errors and that you can use it to make a GET request to /accounts.

Verify your solution

Load the solution /files/module06/accounts-mod06-debugging-solution.jar (in the MUFundamentals4.x DIY Files zip that you can download from the Course Resources) and compare your solution.



Did you complete the exercise?

  Yes, I completed the exercise

  No, I did not complete the exercise

  I completed part of the exercise


Comments and/or feedback